﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Services;
using AppDAL;
using AppBIZ;
using AppUtility;

namespace UIDocument
{
    public partial class WebForm3 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        
        }
        [WebMethod]
        public static JsonResponse Login(string userid, string password)
        {
            try
            {  
                Person person = new Person();
                person.UserId = userid;
                person.Password = password;
                BizPerson bizPerson = new BizPerson();
                person = bizPerson.Login(person);
                if (person != null)
                {
                    HttpContext.Current.Session["LogedUser"] = person;
                    return new JsonResponse() { Data = true, ErrorMessage = null, StatusCode = JsonResponse.Status.Success };
                }
                return new JsonResponse() { Data = false, ErrorMessage = null, StatusCode = JsonResponse.Status.Failed };
            }
            catch (Exception ex)
            {
                HttpContext.Current.Response.Clear();
                HttpContext.Current.Response.StatusCode = 500;             
                return new JsonResponse() { Data = null, ErrorMessage = ex.Message, StatusCode = JsonResponse.Status.Failed };
            }
        }



       //    [WebMethod]
       // public static JsonResponse EducationDetail(string schoolName, string rollNumber,
       //     string className, string registrationNumber, string semesterName,
       //     string boardName, int totalSubject, int totalMark,
       //     int getMarks, int passingOfYear, string fileName)

       ////public static JsonResponse EducationDetail(EducationDetail educationDetail)

       //     {
       //     try
       //         {
       //         EducationDetail _educationDetail = new AppDAL.EducationDetail();

       //         _educationDetail.CollegeName = schoolName;
       //         _.RollNumber = Convert.ToInt16(rollNumber);
       //         _educationDetail.CourseName = className;
       //         _educationDetail.RegistrationNumber = Convert.ToDecimal(registrationNumber);
       //         _educationDetail.SemesterName = semesterName;
       //         _educationDetail.UniversityName = boardName;
       //         _educationDetail.TotalSubject = Convert.ToInt16(totalSubject);
       //         _educationDetail.TotalMark = Convert.ToInt16(totalMark);
       //         _educationDetail.obtainMarks = getMarks.ToString();
       //         _educationDetail.PassYear = passingOfYear;
       //         _educationDetail.FileName = fileName;
       //         var person = (Person)HttpContext.Current.Session["LogedUser"];
       //         _educationDetail.UserId = person.PersonId;
       //         AppBIZ.BizEducationDetail bizEducationDetail = new BizEducationDetail();

       //         int x = bizEducationDetail.SaveEducationDetail(_educationDetail);
       //         if (x >= 0)
       //             {
       //             var lstEmployeeDetail  = 
       //            // return new JsonResponse() { Data = true, ErrorMessage = null, StatusCode = JsonResponse.Status.Success },
                    
       //             }
       //         return new JsonResponse() { Data = false, ErrorMessage = "Eroor", StatusCode = JsonResponse.Status.Failed };
       //         }
       //     catch (Exception ex)
       //         {
       //         string errorMessage = ex.Message;
       //         HttpContext.Current.ClearError();
       //         return new JsonResponse() { Data =false ,ErrorMessage =errorMessage , StatusCode = JsonResponse.Status.Failed };
       //         }
       //     }
        
        [WebMethod]
        public static JsonResponse Logout()
            {
            HttpContext.Current.Session.Abandon();
            return new JsonResponse() {Data="Success", ErrorMessage=null, StatusCode=JsonResponse.Status.Success };
            }

        protected void Button1_Click(object sender, EventArgs e)
            {
          //  System.Threading.Thread.Sleep(3000);
           string [] st=   Str("Vinay/Kumar/Pandey","Vinay");
            }

        private string[] Str(string a ,string b)
            {

            string s = a.Remove(0, b.Length).Trim();
            string[] s1 = s.Split('/');
            return s1;
            }

       
    }
}